<template>
  <div class="adviceMV">
    <div class="title">
      <span>
        推荐MV
        <i class="iconfont iconarrow-right"></i>
      </span>
    </div>
    <div class="MVbody">
      <div v-for="item in MVList" :key="item.id" class="MVDetail">
        <img :src="item.picUrl" alt width="200" height="90" />
        <div class="MVCount">
          <i class="iconfont icon24gl-play"></i>
          <span>{{playCount(item.playCount)}}</span>
        </div>
        <div class="MVName">
          <div>{{item.name}}</div>
          <div>{{item.artistName}}</div>
        </div>
      </div>
    </div>
  </div>
</template>

<script setup lang="ts">
type adviceMVT = {
  id: number
  name: string
  picUrl: string
  playCount: number
  artistName: string
}
import { computed, onMounted, ref } from 'vue'
import axios from '@/http.ts'
onMounted(() => {
  getAdviceMVList()
})
const playCount = computed(() => count => {
  return count > 10000 ? Math.ceil(count / 10000) + '万' : count
})
const MVList = ref<Array<adviceMVT>>([])
const getAdviceMVList = () => {
  axios.get('/personalized/mv').then(res => {
    console.log(res)
    res.data.code === 200 && (MVList.value = res.data.result)
  })
}
</script>

<style lang="less" scoped>
.adviceMV {
  overflow: scroll;
  padding: 16px;
  margin-bottom: 30px;
  .title {
    color: #b2b2b2;
    overflow: hidden;
    font-weight: bolder;
    margin-bottom: 10px;
    margin-left: 20px;
    &:hover {
      color: #fff;
      cursor: pointer;
    }
  }
  .MVbody {
    text-align: center;
    display: flex;
    justify-content: space-around;
    .MVDetail {
      flex: 1;
      position: relative;
      white-space: nowrap;
      text-overflow: ellipsis;
      overflow: hidden;
      .MVCount {
        position: absolute;
        font-size: 12px;
        font-weight: bolder;
        color: #fff;
        right: 30px;
        top: 3px;
        &:hover {
          cursor: pointer;
        }
        .iconfont {
          font-size: 12px;
          margin-right: 3px;
        }
      }
      img {
        border-radius: 5px;
        &:hover {
          cursor: pointer;
        }
      }
      .MVName {
        padding: 0 18px;
        div {
          margin: 0;
          text-align: left;
          overflow: hidden;
          white-space: nowrap;
          text-overflow: ellipsis;
          &:nth-child(1) {
            color: #b3b3b3;
            font-size: 14px;
            font-weight: bolder;

            &:hover {
              color: #fff;
              cursor: pointer;
            }
          }
          &:nth-child(2) {
            color: #676767;
            font-size: 12px;
            &:hover {
              color: #878787;
              cursor: pointer;
            }
          }
        }
      }
    }
  }
}
</style>